package com.koron.sinoprobe.web.plan.bean.vo;

import com.koron.sinoprobe.web.plan.bean.entity.SpPlanMilestone;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

/**
 * @author twcao
 * @title: SpPlanMilestoneVO
 * @projectName GDH_EAM_V2
 * @description: 里程碑列表
 * @date 2021/12/28:57
 */
@Data
@ApiModel(description = "专项项目/计划-里程碑")
public class SpPlanMilestoneVO extends SpPlanMilestone {

    @ApiModelProperty("实际历时（天），如无法计算返回null")
    private Integer duration;

    @ApiModelProperty("实际进度 百分比")
    private Float percentage;

    public Integer getDuration() {
        if(ObjectUtils.allNotNull(this.getFactStartTime(), this.getFactEndTime())) {
            return (int)((this.getFactEndTime().getTime() - this.getFactStartTime().getTime()) / (24 * 3600 * 1000));
        }
        return null;
    }
}
